set -e

QNX_DIR=$1
if [ $# -lt 1 ];
then
    echo "default path"
    QNX_DIR=~/workspace/qnx700
fi
source ${QNX_DIR}/qnxsdp-env.sh

BUILD_DIR=$(pwd)/.build
INSTALL_DIR=$(pwd)/.output

if [ ! -d $BUILD_DIR ]; then
    mkdir -p $BUILD_DIR
fi

if [ ! -d $INSTALL_DIR ]; then
    mkdir -p $INSTALL_DIR
fi

#########################################################
#
# compile vehicle
#
if [ ! -d $BUILD_DIR ]; then
    mkdir -p $BUILD_DIR
fi

cmake -S ./ -B $BUILD_DIR -G "Unix Makefiles" \
        -DCMAKE_BUILD_TYPE=Debug \
        -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_DIR \
        -DNOSAL_TARGET_MACHINE=QNX-SA8155
cmake --build $BUILD_DIR
cmake --install $BUILD_DIR

